using System;
using System.Collections.Generic;
using System.Text;
using System.Data;

namespace DTO
{
	/// <summary> 
	///Author: daiduong19051986@gmail.com 
	/// <summary>
	
    public class IunitsInfo
    {
		#region Local Variable
		public enum Field
		{
			Monedb,
			Unit,
			Description,
			Lookup,
			Status,
			Createdby,
			Insertpointotime,
			Updatedby,
			LastUpdate
		}
		private String _Monedb;
		private String _Unit;
		private String _Description;
		private String _Lookup;
		private String _Status;
		private String _Createdby;
		private DateTime _Insertpointotime;
		private String _Updatedby;
		private DateTime _LastUpdate;
		
		public String Monedb{	get{ return _Monedb;} set{_Monedb = value;} }
		public String Unit{	get{ return _Unit;} set{_Unit = value;} }
		public String Description{	get{ return _Description;} set{_Description = value;} }
		public String Lookup{	get{ return _Lookup;} set{_Lookup = value;} }
		public String Status{	get{ return _Status;} set{_Status = value;} }
		public String Createdby{	get{ return _Createdby;} set{_Createdby = value;} }
		public DateTime Insertpointotime{	get{ return _Insertpointotime;} set{_Insertpointotime = value;} }
		public String Updatedby{	get{ return _Updatedby;} set{_Updatedby = value;} }
		public DateTime LastUpdate{	get{ return _LastUpdate;} set{_LastUpdate = value;} }
		
        #endregion LocalVariable
        
        #region Constructor
		public IunitsInfo()
		{
			_Monedb = "";
			_Unit = "";
			_Description = "";
			_Lookup = "";
			_Status = "";
			_Createdby = "";
			_Insertpointotime = DateTime.Now;
			_Updatedby = "";
			_LastUpdate = DateTime.Now;
		}
		public IunitsInfo(
		String Monedb,
		String Unit,
		String Description,
		String Lookup,
		String Status,
		String Createdby,
		DateTime Insertpointotime,
		String Updatedby,
		DateTime LastUpdate
		)
		{
			_Monedb = Monedb;
			_Unit = Unit;
			_Description = Description;
			_Lookup = Lookup;
			_Status = Status;
			_Createdby = Createdby;
			_Insertpointotime = Insertpointotime;
			_Updatedby = Updatedby;
			_LastUpdate = LastUpdate;
		}
		public IunitsInfo(DataRow dr)
		{
			if (dr != null)
			{
				_Monedb = dr[Field.Monedb.ToString()] == DBNull.Value?"":Convert.ToString(dr[Field.Monedb.ToString()]);
				_Unit = dr[Field.Unit.ToString()] == DBNull.Value?"":Convert.ToString(dr[Field.Unit.ToString()]);
				_Description = dr[Field.Description.ToString()] == DBNull.Value?"":Convert.ToString(dr[Field.Description.ToString()]);
				_Lookup = dr[Field.Lookup.ToString()] == DBNull.Value?"":Convert.ToString(dr[Field.Lookup.ToString()]);
				_Status = dr[Field.Status.ToString()] == DBNull.Value?"":Convert.ToString(dr[Field.Status.ToString()]);
				_Createdby = dr[Field.Createdby.ToString()] == DBNull.Value?"":Convert.ToString(dr[Field.Createdby.ToString()]);
				_Insertpointotime = dr[Field.Insertpointotime.ToString()] == DBNull.Value?DateTime.Now:Convert.ToDateTime(dr[Field.Insertpointotime.ToString()]);
				_Updatedby = dr[Field.Updatedby.ToString()] == DBNull.Value?"":Convert.ToString(dr[Field.Updatedby.ToString()]);
				_LastUpdate = dr[Field.LastUpdate.ToString()] == DBNull.Value?DateTime.Now:Convert.ToDateTime(dr[Field.LastUpdate.ToString()]);
			}
		}
		public IunitsInfo(DataRowView dr)
		{
			if (dr != null)
			{
				_Monedb = dr[Field.Monedb.ToString()] == DBNull.Value?"":Convert.ToString(dr[Field.Monedb.ToString()]);
				_Unit = dr[Field.Unit.ToString()] == DBNull.Value?"":Convert.ToString(dr[Field.Unit.ToString()]);
				_Description = dr[Field.Description.ToString()] == DBNull.Value?"":Convert.ToString(dr[Field.Description.ToString()]);
				_Lookup = dr[Field.Lookup.ToString()] == DBNull.Value?"":Convert.ToString(dr[Field.Lookup.ToString()]);
				_Status = dr[Field.Status.ToString()] == DBNull.Value?"":Convert.ToString(dr[Field.Status.ToString()]);
				_Createdby = dr[Field.Createdby.ToString()] == DBNull.Value?"":Convert.ToString(dr[Field.Createdby.ToString()]);
				_Insertpointotime = dr[Field.Insertpointotime.ToString()] == DBNull.Value?DateTime.Now:Convert.ToDateTime(dr[Field.Insertpointotime.ToString()]);
				_Updatedby = dr[Field.Updatedby.ToString()] == DBNull.Value?"":Convert.ToString(dr[Field.Updatedby.ToString()]);
				_LastUpdate = dr[Field.LastUpdate.ToString()] == DBNull.Value?DateTime.Now:Convert.ToDateTime(dr[Field.LastUpdate.ToString()]);
			}
		}
		public IunitsInfo(IunitsInfo objEntr)
		{			
			_Monedb = objEntr.Monedb;			
			_Unit = objEntr.Unit;			
			_Description = objEntr.Description;			
			_Lookup = objEntr.Lookup;			
			_Status = objEntr.Status;			
			_Createdby = objEntr.Createdby;			
			_Insertpointotime = objEntr.Insertpointotime;			
			_Updatedby = objEntr.Updatedby;			
			_LastUpdate = objEntr.LastUpdate;			
		}
        #endregion Constructor
        
        #region InitTable
		public DataTable ToDataTable()
		{
			DataTable dt = new DataTable("Iunits");
			dt.Columns.AddRange(new DataColumn[] { 
				new DataColumn(Field.Monedb.ToString(), typeof(String)),
				new DataColumn(Field.Unit.ToString(), typeof(String)),
				new DataColumn(Field.Description.ToString(), typeof(String)),
				new DataColumn(Field.Lookup.ToString(), typeof(String)),
				new DataColumn(Field.Status.ToString(), typeof(String)),
				new DataColumn(Field.Createdby.ToString(), typeof(String)),
				new DataColumn(Field.Insertpointotime.ToString(), typeof(DateTime)),
				new DataColumn(Field.Updatedby.ToString(), typeof(String)),
				new DataColumn(Field.LastUpdate.ToString(), typeof(DateTime))
			});
			return dt;
		}
		public DataRow ToDataRow(DataTable dt)
		{
			DataRow row = dt.NewRow();
			row[Field.Monedb.ToString()] = _Monedb;
			row[Field.Unit.ToString()] = _Unit;
			row[Field.Description.ToString()] = _Description;
			row[Field.Lookup.ToString()] = _Lookup;
			row[Field.Status.ToString()] = _Status;
			row[Field.Createdby.ToString()] = _Createdby;
			row[Field.Insertpointotime.ToString()] = _Insertpointotime;
			row[Field.Updatedby.ToString()] = _Updatedby;
			row[Field.LastUpdate.ToString()] = _LastUpdate;
			return row;
		}
        #endregion InitTable
    }
}
